package com.cangxuan.backend.dao;

import com.cangxuan.backend.entity.Goods;
import com.cangxuan.backend.entity.OrderForm;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IOrderFormDao {

    @Insert("insert into orderform values(default,#{buyerId},#{sellerId},#{goodsId},#{price},#{count},#{transAmount},#{free},#{actualReceipt},now(),null,1,#{registrationId})")
    @Options(
            keyProperty = "id",
            useGeneratedKeys = true
    )
    int createOrderForm(OrderForm orderForm);

    OrderForm selectByIdForUpdate(int orderId);

    int updateForSuccessPay(int orderId);

    int updateForCancel(int orderId);

    OrderForm selectById(int orderFormId);

    int selectUserHavaOrderForm(int buyerId);

    List<OrderForm> selectOrderForm(@Param("comeFrom") int comeFrom,@Param("state") int state,@Param("userId") int userId);

    List<OrderForm> selectOverTimeOderForm();

    int selectIsOverTime(int id);

    int updateCount(@Param("id") int id,@Param("max") int max,@Param("transAmount") float transAmount);


}
